package com.qf.listener;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class DleQueueListener {

    @RabbitListener(queues = "dle-queue")
    public void delQueueMsg(String msg, Channel channel, Message message) throws IOException {
        String data = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
        System.out.println("死信队列 --> " + data + " -- >" + msg);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }
}
